#ifndef VROTE_TASKMANAGER_HPP_3
#define VROTE_TASKMANAGER_HPP_3

#include "vroute_stack.hpp"
#include "vroute_sys.hpp"

namespace vroute_stack
{
    typedef enum _taskTimerTime
    {
        task_timer_ms_500,
        task_timer_sec_1,
        task_timer_sec_5,
        task_timer_sec_30,
        task_timer_min_1
    }taskTimerTime;

    const unsigned int errTaskId = 0xFFFFFFFF;
    const int max_task_term_count = 20;

    Interface IJob;
    class CTaskMgr
    {
    public:
        static CTaskMgr* getInstance();
        static void releaseInstance();

        int init(SystemStartType type);

        static vos_threadRetType run_ms_500(void* p);
        vos_threadRetType run_ms_500_ins();
        static vos_threadRetType run_sec_1(void* p);
        vos_threadRetType run_sec_1_ins();
        static vos_threadRetType run_sec_5(void* p);
        vos_threadRetType run_sec_5_ins();
        static vos_threadRetType run_sec_30(void* p);
        vos_threadRetType run_sec_30_ins();
        static vos_threadRetType run_min_1(void* p);
        vos_threadRetType run_min_1_ins();

        virtual unsigned int registTask(IJob* job, taskTimerTime type);
        virtual int removeTask(unsigned int taskId);

    private:
        CTaskMgr();
        virtual ~CTaskMgr();

    private:
        static CTaskMgr* _instance;
        IJob** m_job_ms_500;
        int m_job_count_ms_500;
        IJob** m_job_sec_1;
        int m_job_count_sec_1;
        IJob** m_job_sec_5;
        int m_job_count_sec_5;
        IJob** m_job_sec_30;
        int m_job_count_sec_30;
        IJob** m_job_min_1;
        int m_job_count_min_1;
        vos_criticalSection m_cs_task; 
        int m_working;
    };
}
#endif //VROTE_TASKMANAGER_HPP_3